package com.gitee.mars.vaccin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gitee.mars.vaccin.entity.SysMenu;
import com.gitee.mars.vaccin.response.base.BasePageRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 持久层
 *
 * @Author wq
 * @Date 2020-12-15
 **/
@Mapper
public interface SysMenuMapper extends BaseMapper<SysMenu> {

    IPage<SysMenu> findByQuery(IPage<SysMenu> page, @Param("query") BasePageRequest query);

    /**
     * 查询用户的权限
     *
     * @param roleId 角色ID
     * @return 权限集合
     */
    List<String> selectPermissions(Integer roleId);

    /**
     * 查询该父级菜单下的子菜单
     *
     * @param id id
     * @return SysMenu
     */
    List<SysMenu> selectChildren(@Param("id") Integer id);

    /**
     * 根据角色ID查询菜单
     *
     * @param roleId roleId
     * @return List<SysMenu>
     */
    List<SysMenu> selectMenusRoleId(@Param("roleId") Integer roleId);
}
